from PyQt5 import QtCore
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel


class MessageTip(QDialog):
    def __init__(self, app, msg):
        super().__init__()
        print("子窗口")
        self.app = app
        self.msg = msg
        self.initUI()
        self.setWindowFlags(
            self.windowFlags() & ~QtCore.Qt.WindowType.WindowContextHelpButtonHint & ~QtCore.Qt.WindowType.WindowCloseButtonHint)

    def initUI(self):
        self.resize(200, 150)
        self.setWindowTitle("提示")
        # 创建布局
        layout = QVBoxLayout()
        layout.addWidget(QLabel(self.msg))
        # 将网格布局应用到当前窗口
        self.setLayout(layout)
        self.set_center()

    def set_center(self):
        desktop = self.app.desktop()
        # 需要int类型的数据，float可能在后续版本会删除
        self.move(int((desktop.width() / 2 - self.width() / 2)), int((desktop.height() - self.height()) / 2))
